﻿using AutoMapper;
using Edu.Contracts;
using Volo.Abp.Identity;

using CreateUserModalModel = Volo.Abp.Extension.Web.Pages.Identity.Users.CreateModalModel;
using EditUserModalModel = Volo.Abp.Extension.Web.Pages.Identity.Users.EditModalModel;


namespace Volo.Abp.Extension.Web
{
    public class VoloAbpExtensionWebAutoMapperProfile : Profile
    {
        public VoloAbpExtensionWebAutoMapperProfile()
        {
            CreateUserMappings();
        }

        private void CreateUserMappings()
        {
            //List
            CreateMap<EduUserDto, EditUserModalModel.UserInfoViewModel>();

            //CreateModal
            CreateMap<CreateUserModalModel.UserInfoViewModel, IdentityUserCreateDto>()
                .ForMember(dest => dest.RoleNames, opt => opt.Ignore());

            CreateMap<IdentityRoleDto, CreateUserModalModel.AssignedRoleViewModel>()
                .ForMember(dest => dest.IsAssigned, opt => opt.Ignore());

            CreateMap<CreateUserModalModel.UserInfoViewModel, EduUserUpdateDto>();

            //EditModal
            CreateMap<EditUserModalModel.UserInfoViewModel, IdentityUserUpdateDto>()
                .ForMember(dest => dest.RoleNames, opt => opt.Ignore());

            CreateMap<IdentityRoleDto, EditUserModalModel.AssignedRoleViewModel>()
                .ForMember(dest => dest.IsAssigned, opt => opt.Ignore());

            CreateMap<EditUserModalModel.UserInfoViewModel, EduUserUpdateDto>();

        }



    }
}
